<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // console.log(Math.random())

    // 0-10之间的整数
    // console.log(Math.floor(Math.random() * 11))

    // let arr = ['red', 'green', 'yellow']
    // let random = Math.floor(Math.random() * arr.length)
    // console.log(arr[random])

    function getRandom(N, M) {
      return Math.floor(Math.random() * (M - N + 1)) + N
    }
    console.log(getRandom(4, 8))
    
  </script>
</body>
</html> 